home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH08 / PGM8_1.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-02-02  |  989 b   |  61 lines

  1. ; Example of a reasonably well-formatted program.
  2.  
  3.  
  4. dseg        segment    para public 'data'
  5.  
  6. ; Some type definitions for the variables we will declare:
  7.  
  8. uint        typedef    word        ;Unsigned integers.
  9. integer        typedef    sword        ;Signed integers.
  10.  
  11.  
  12. ; Some variables we can use:
  13.  
  14. j        integer    ?
  15. k        integer    ?
  16. l        integer    ?
  17.  
  18. u1          uint    ?
  19. u2        uint    ?
  20. u3        uint    ?
  21.  
  22. dseg        ends
  23.  
  24. cseg        segment    para public 'code'
  25.         assume    cs:cseg, ds:dseg
  26.  
  27. Main        proc
  28.         mov    ax, dseg
  29.         mov    ds, ax
  30.         mov    es, ax
  31.  
  32. ; Initialize our variables:
  33.  
  34.         mov    j, 3
  35.         mov    k, -2
  36.  
  37.         mov    u1, 254
  38.         mov    u2, 22
  39.  
  40. ; Compute L := j+k and u3 := u1+u2
  41.  
  42.         mov    ax, J
  43.         add    ax, K
  44.         mov    L, ax
  45.  
  46.         mov    ax, u1        ;Note that we use the "ADD"
  47.         add    ax, u2        ; instruction for both signed
  48.         mov    u3, ax        ; and unsigned arithmetic.
  49.  
  50.  
  51. Quit:        mov    ah, 4ch        ;DOS opcode to quit program.
  52.         int    21h        ;Call DOS.
  53. Main        endp
  54.  
  55. cseg        ends
  56.  
  57. sseg        segment    para stack 'stack'
  58. stk        byte    1024 dup ("stack   ")
  59. sseg        ends
  60.         end    Main
  61.